function checkFormElements(formObj){
	var ele;
	if(formObj == null) {
		ele = document.forms[0].elements;
	} else {
		ele = formObj.elements;
	}
	for (i = 0; i < ele.length; i++)
	{
		//alert(ele[i].tagName+"%%%"+ele[i].type);
		if(ele[i].disabled)continue;
		if(ele[i].readOnly)continue;
        if (ele[i].type == 'text' || ele[i].type == 'file' || ele[i].type == 'textarea' || ele[i].type == 'password' || ele[i].type == 'select-one') 
		{
            if (isNull1(ele[i]) == false) 
			{
				if(typeof ele[i].getAttribute("note")=="undefined"){
					if(ele[i].type == 'select-one'){
						alert("\u5FC5\u9009\u9879\u5FC5\u987B\u9009\u62E9");
					}else{
						alert("\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A");
					}
				}else{
					if(ele[i].type == 'select-one'){
						alert("\u8BF7\u9009\u62E9"+ele[i].getAttribute("note"));
					}else{
						alert(ele[i].getAttribute("note")+"\u5FC5\u987B\u586B\u5199");
					}
				}
				if(typeof ele[i].value!="undefined"&&ele[i].value!=""&&ele[i].type != "select-one") ele[i].select();
				else ele[i].focus();
                return false;
            }
			if (checkData(ele[i]) == false)
			{
				if(typeof ele[i].value!="undefined"&&ele[i].value!=""&&ele[i].type != "select-one") ele[i].select();
				else ele[i].focus();
                return false;
			}
        }
    }
    return true;
}
function checkData(o)
{
	var datatype=o.datatype;
	if(IsSpace(datatype)==false){
		if (datatype.toLowerCase()=="number"||datatype.toLowerCase()=="double"||datatype.toLowerCase()=="numeric"){
			if (checkEleNumber(o) == false)
			{
				if(typeof o.getAttribute("note")=="undefined"){
					alert("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u6570\u5B57");
				}else{
					alert(o.getAttribute("note")+"\u5FC5\u987B\u662F\u6570\u5B57");
				}
				return false;
			}
		}
		if (datatype.toLowerCase()=="int" || datatype.toLowerCase()=="integer"){
			if (isEleNumber(o.value) == false)
			{
				if(typeof o.getAttribute("note")=="undefined"){
					alert("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u6B63\u6574\u6570");
				}else{
					alert(o.getAttribute("note")+"\u5FC5\u987B\u662F\u6B63\u6574\u6570");
				}
				return false;
			}
		}
		if (datatype.toLowerCase()=="int_pn" || datatype.toLowerCase()=="integer_pn"){
			if (isEleNumber_PN(o.value) == false)
			{
				if(typeof o.getAttribute("note")=="undefined"){
					alert("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u6574\u6570");
				}else{
					alert(o.getAttribute("note")+"\u5FC5\u987B\u662F\u6574\u6570");
				}
				return false;
			}
		}
		if (datatype.toLowerCase()=="date"){   //yyyy-MM-dd yyyy-MM-dd hh:mm
			if(IsSpace(o.value)==false){
				if (!CheckEleDate(o.value)&&!checkEleDateMinute(o.value))
				{
					if(typeof o.getAttribute("note")=="undefined"){
						alert("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u65E5\u671F\u683C\u5F0F");
					}else{
						alert(o.getAttribute("note")+"\u5FC5\u987B\u662F\u65E5\u671F\u683C\u5F0F");
					}
					return false;
				}
			}
		}	
		if (datatype.toLowerCase()=="dateminute"){   //yyyy-MM-dd hh:mm
			if(IsSpace(o.value)==false){
				if (!checkEleDateMinute(o.value))
				{
					if(typeof o.getAttribute("note")=="undefined"){
						alert("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u65F6\u95F4\u683C\u5F0F,\u59821900-12-31 12:13\u62161900/12/31 12:13");
					}else{
						alert(o.getAttribute("note")+"\u5FC5\u987B\u662F\u65F6\u95F4\u683C\u5F0F,\u59821900-12-31 12:13\u62161900/12/31 12:13");
					}
					return false;
				}
			}
		}
	}
	return true;
}
function CheckEleDate(val){
	if(isDate(val,"yyyy-MM-dd")||isDate(val,"yyyy/MM/dd")){
		return true;
	}else{
		return false;
	}
}
function checkEleDateMinute(val){
	if(isDate(val,"yyyy-MM-dd HH:mm")||isDate(val,"yyyy/MM/dd HH:mm")){
		return true;
	}else{
		return false;
	}
}
function isEleNumber( s ){
	if(s=="")
		return true;
	var regu = "^[0-9]+$";
	var re = new RegExp(regu);
	if (s.search(re) != -1) {
	   return true;
	} else {
	   return false;
	}
	return true;
}
function isEleNumber_PN( s ){
	if(s=="")
		return true;
	var regu = "^[+-]?[0-9]+$";
	var re = new RegExp(regu);
	if (s.search(re) != -1) {
	   return true;
	} else {
	   return false;
	}
	return true;
}


function checkEleNumber(o)
{
	var temp="-.0123456789";
	var tocheck = o.value;
	var num = 0;
	for (j=0;j<tocheck.length;j++){
		var str = tocheck.substring(j,j+1);
		if (temp.indexOf(str)<0) return false;
		//取得 . 的数目
		if(str==".") num++;
	}
	if(num>1) return false;
	return true;
}
function isNull1(o) 
{
    if (o.notnull) 
	{
		if(o.type=="select-one"){
			if (o.notnull == "true" && (cTrim(o.value,0) == ''||o.value=='0')) return false;
		}else{
			if (o.notnull == "true" && (cTrim(o.value,0) == ''||o.value.replace(/^\s*|[\x00-\x1f]|\s*$/g,'') == '')) return false;
		}
    }
    return true;
}
function cTrim(sInputString,iType)
{
	var sTmpStr = ' ';
	var i = -1;
	
	if(iType == 0 || iType == 1)
	{
		while(sTmpStr == ' ')
		{
			++i;
			sTmpStr = sInputString.substr(i,1);
		}
		sInputString = sInputString.substring(i);
	}	
	if(iType == 0 || iType == 2)
	{
		sTmpStr = ' ';
		i = sInputString.length;
		while(sTmpStr == ' ')
		{
			--i;
			sTmpStr = sInputString.substr(i,1);
		}
		sInputString = sInputString.substring(0,i+1);
	}
	return sInputString;
}
function IsSpace(val){
	if(typeof val=="undefined")return true;
	if(cTrim(val,0)== ''){
		return true;
	}else{
		return false;
	}
}